﻿package com.reyco1.extension
{
	/*
	Imports
	*/
	import flash.display.Sprite;
	import com.reyco1.util.ClassUtil
	/*
	Class
	*/
	public class StandardExtension extends Sprite
	{
		/*
		Variables
		*/
		private var strClassName:String;
		private var bolOutputSilenced:Boolean = false;
		/*
		Constructor
		*/
		
		/**
		 * To be used by classes which extend flash.display.Sprite to which you wish to apply advanced output functionality to.
		 * 
		 */
		public function StandardExtension():void
		{
			this.strClassName = ClassUtil.displayClassName(this);
			trace(this.strClassName + "constructed")
		}	
		/*
		Output function
		*/
		
		/**
		 * Allows all classes which extend StandardExtension to be able to use a more detailed logging system
		 * @param $output : Number, String, Object or Array
		 * 
		 */
		public function output($output:*):void
		{
			if(!this.bolOutputSilenced){
				switch(typeof($output)){
					
					case "object":
					var type:String = ($output.length) ? "Array" : "Object";
					trace(this.strClassName + type)
					trace("----------------------------------------------");
					for (var prop:* in $output) { 
						trace("  - ["+typeof($output[prop])+"]  "+prop+" : "+$output[prop]); 
					}
					break;
									
					default:
					trace(this.strClassName + $output)
					break;
				}
			}
		}
		
		/**
		 * Togles the output functionality of the extending class
		 * @param $bol
		 * 
		 */	
		public function set outputSilenced($bol:Boolean):void
		{
			this.bolOutputSilenced = $bol
		}
	}
}


